//
//  CALayer+Extension.swift
//  YangFoundation
//
//  Created by yuyang on 2021/12/21.
//

import Foundation

public extension CALayer {
    func tranform(angle: CGFloat, scale: CGFloat, isAdd: CATransform3D? = nil) -> CATransform3D {
        
        let transIdentify = CATransform3DIdentity
        let transRotate = CATransform3DRotate(transIdentify, angle, 0, 0, 1)
        let transScale = CATransform3DScale(transRotate, scale, scale, 1)
        if isAdd != nil {
            return CATransform3DConcat(transScale,isAdd!)
        }
        
        return transScale
    }
    
    func tranform(_ t: CATransform3D?, angle: CGFloat, scale: CGFloat, isAdd: Bool = false) -> CATransform3D {
        
        let transIdentify = CATransform3DIdentity
        let transRotate = CATransform3DRotate(transIdentify, angle, 0, 0, 1)
        let transScale = CATransform3DScale(transRotate, scale, scale, 1)
        if t != nil {
            return CATransform3DConcat(t!, transScale)
        }
        
        return transScale
    }
}
